import { file, write, $ } from 'bun'
import { consola as logger } from 'consola'

const pkg = await file('package.json').json()

console.log(pkg);

logger.info('准备发布event')
pkg.name = '@moretime/weapp-event';
write('./src/event/package.json', JSON.stringify(pkg, null, 2));
await $`cd src/event && npm publish`;

logger.info('准备发布toast')
pkg.name = '@moretime/weapp-toast';
write('./src/toast/package.json', JSON.stringify(pkg, null, 2));
await $`cd src/toast && npm publish`;

await $`git add . && git commit -m "publish end" && git push`